var t = getApp(),
    a = t.requirejs("core"),
    e = t.requirejs("jquery");
Page({
  data: {
    province: [
      {id:1,name:"黑龙江"},
      {id:2,name:"青海"},
      {id:3,name:"上海"},
      {id:4,name:"甘肃"},
      {id:5,name:"黑海"},
    ],
    city: [],
    search: "",
    provincetext: "",
    provinceid: "",
    provinceactive: "",
    citytext: "",
    cityid: "",
    cityactive: "",
  },
  onLoad: function () {
    var that = this;
    that.getList()
  },
  onShow: function() {},
  getList: function() {
    var that = this;
    // a.get("changce/merch/get_list", {
      
    // }, function(e) {
      that.setData({
        show: !0
      })
    // })
  },
  bindput: function(event){
    this.setData({search: event.detail.value});
  },
  prolist: function(){
    var that = this;
    // a.get("changce/merch/get_list", {
      
    // }, function(e) {
      var list = [{id:6,name: "保安市"},{id:7,name: "保安2市"},{id:8,name: "保安3市"},{id:9,name: "保安4市"},{id:10,name: "保安5市"}];
      that.setData({
        city: list
      })
    // })
  },
  province: function(event){
    var that = this, 
        id = event.currentTarget.dataset.id,
        name = event.currentTarget.dataset.name,
        provinceactive = that.data.provinceactive;
    if(id == provinceactive){
      that.setData({
        provincetext: "",
        provinceid: "",
        provinceactive: "",
      })
    }else{
      that.setData({
        provincetext: name,
        provinceid: id,
        provinceactive: id,
      }), that.prolist();
    }
    that.setData({
      citytext: "",
      cityid: "",
      cityactive: "",
    }), that.setData(that.data);
  },
  city: function(event){
    var that = this, 
        id = event.currentTarget.dataset.id,
        name = event.currentTarget.dataset.name,
        cityactive = that.data.cityactive;
    if(id == cityactive){
      that.setData({
        citytext: "",
        cityid: "",
        cityactive: "",
      })
    }else{
      that.setData({
        citytext: name,
        cityid: id,
        cityactive: id,
      })
    }
    that.setData(that.data);
  },
  success: function(){
    var that = this, search = that.data.search, province = that.data.provincetext,
        provid = that.data.provinceid, city = that.data.citytext, cityid = that.data.cityid,
        stype = 1, pages = getCurrentPages(), prevPage = pages[pages.length - 2]; // 上一个页面
    prevPage.setData({
      search: search,
      province: province,
      provid: provid,
      city: city,
      cityid: cityid,
      stype: stype,
      selectcover: false,
      selected: "",
    })
    wx.navigateBack({ delta: 1, });
  },
})
